//
//  DelegateTableViewCell.m
//  UI_14_ScrollerDelegate
//
//  Created by dllo on 16/3/28.
//  Copyright © 2016年 XWH. All rights reserved.
//

#import "DelegateTableViewCell.h"


@implementation DelegateTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.button = [[UIButton alloc] initWithFrame:CGRectZero];
        self.scroll = [[UIScrollView alloc] initWithFrame:CGRectZero];
        self.label = [[UILabel alloc] initWithFrame:CGRectZero];
    }
    return self;
}

-(void)layoutSubviews{
    
    self.scroll.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.scroll.contentOffset = CGPointMake(0, 0);
    
    self.scroll.contentSize = CGSizeMake(self.frame.size.width + 60, 0);
    
    self.scroll.showsHorizontalScrollIndicator = NO;
    self.scroll.bounces = NO;
    self.scroll.pagingEnabled = YES;
    self.scroll.backgroundColor = [UIColor orangeColor];
    [self addSubview:self.scroll];
    
    self.label.frame = CGRectMake(5, 5, 150, 30);
    [self.scroll addSubview:self.label];
    
    self.button.frame = CGRectMake(self.frame.size.width, 0, 60, 44);
    self.button.backgroundColor = [UIColor redColor];
    [self.button setTitle:@"删除" forState:UIControlStateNormal];
    [self.button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.scroll addSubview:self.button];
    
    
}

-(void)setModel:(DelegateModel *)model{
    
    self.label.text = model.name;

}


-(void)buttonAction:(UIButton *)sender{
    [self.delet deletData:self];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
